package com.gxa.jd.controller.front;
import com.gxa.entity.PageResult;
import com.gxa.entity.Result;
import com.gxa.jd.pojo.GoodsOrder;
import com.gxa.jd.service.GoodsOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/order")
public class GoodsOrderController {

    @Autowired
    private GoodsOrderService goodsOrderService;

    @GetMapping("/findAll")
    public List<GoodsOrder> findAll(){
        return goodsOrderService.findAll();
    }

    @GetMapping("/findPage")
    public PageResult<GoodsOrder> findPage(int page, int size){
        return goodsOrderService.findPage(page, size);
    }

    @PostMapping("/findList")
    public List<GoodsOrder> findList(@RequestBody Map<String,Object> searchMap){
        return goodsOrderService.findList(searchMap);
    }

    @PostMapping("/findPage")
    public PageResult<GoodsOrder> findPage(@RequestBody Map<String,Object> searchMap, int page, int size){
        return  goodsOrderService.findPage(searchMap,page,size);
    }

    @GetMapping("/findById")
    public GoodsOrder findById(String orderId){
        return goodsOrderService.findById(orderId);
    }


    @PostMapping("/add")
    public Result add(@RequestBody GoodsOrder goodsOrder){
        goodsOrderService.add(goodsOrder);
        return new Result();
    }

    @PostMapping("/update")
    public Result update(@RequestBody GoodsOrder goodsOrder){
        goodsOrderService.update(goodsOrder);
        return new Result();
    }

    @GetMapping("/delete")
    public Result delete(String orderId){
        goodsOrderService.delete(orderId);
        return new Result();
    }

}
